package com.hgdp.medicalexamination.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hgdp.medicalexamination.entity.DicFolk;
import com.hgdp.medicalexamination.mapper.DicFolkMapper;
import com.hgdp.medicalexamination.service.DicFolkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @param 
 * @author hgdp
 * @date 2020-07-30 10:36:49
 */
@RestController
@AllArgsConstructor
@Api(value = "操作接口")
@RequestMapping("/dicfolk")
public class DicFolkController {

    private DicFolkService dicFolkService;
    private DicFolkMapper dicFolkMapper;

    /**
   	  * 列表
     */
    @ApiOperation(value = "分页查询", notes = "分页查询dicFolk ")
  	@GetMapping("/pagelist")
    public R list(Page page, DicFolk dicFolk){
        return R.ok(dicFolkService.queryPage(page,dicFolk));
    }

    /**
     * 列表
     */
    @ApiOperation(value = "查询", notes = "查询dicFolk ")
    @GetMapping("/list")
    public R list(){
        return R.ok(dicFolkMapper.selectList(null));
    }
    /**
     * 信息
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询dicFolk ")   
    @GetMapping("/info/{code}")
    public R info(@PathVariable("code") String code){
        return R.ok(dicFolkService.getById(code));
    }

    /**
     * 保存
     */
     @ApiOperation(value = "保存", notes = "保存") 
  	@PostMapping("/save")
    public R save(@RequestBody DicFolk dicFolk){
        return R.ok(dicFolkService.save(dicFolk));
    }


   /**
    * 修改
    * @param dicFolk 
    * @return R
    */
    @ApiOperation(value = "修改", notes = "修改")    
    @PutMapping("/update")
    public R update(@RequestBody DicFolk dicFolk){
        return R.ok(dicFolkService.updateById(dicFolk));
    }

    /**
     * 删除
     */
    @ApiOperation(value = "通过id删除", notes = "通过id删除")    
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] codes){
        return R.ok(dicFolkService.removeByIds(Arrays.asList(codes)));
    }
}